;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var dialog = require("dialog");
	var router = require("../hash/pageRouter");
	var databind = require("databind");
	var css_riskWarningScheme = require("./warningSchemeList.css");
	var oData = {
		pageIndex: 1,
		pageSize: 10, 
		totalPageCount: 1, 
		totalRecordCount: 0
	}
	var tools = require("tools");
	var init = function() {
		router.init();
		
		tools.loadList("inquireWarningSchemePageList.json", $("#warningSchemeTable"), $("#warningSchemeTpl"), oData, function(){
			//详情
			$("#warningSchemeList .detail").unbind("click").click(function(){
				router.route("auditWarning/warningSchemeCreate.html?schemeId=" + $(this).parents("tr").attr("schemeId"));
			});
			
			//删除
			$("#warningSchemeList .delete").unbind("click").click(function(){
				var $this = $(this);
				dialog.showConfirmDialog("删除", "是否确认删除该条预警方案？", function(){
					removeWarningScheme($this.parents("tr").attr("schemeId"));
				});
			});
		});
		
		initEvent();
	};
	
	var initEvent = function() {
		// 若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == ""|| base.getData("sid") == undefined) {
			top.location.href = "../login/login.html";
		}
		
		//新增
		$("#warningSchemeList .createWarningScheme").unbind("click").click(function(){
				router.route("auditWarning/warningSchemeCreate.html");
			});
	};
	
	// 删除预警方案
	var removeWarningScheme = function(schemeId) {
		base.fnAjax({
			action: "removeWarningScheme.json", //接口名称
			oData: {
				schemeId: schemeId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					base.alert(1, "删除成功!");
					router.route("auditWarning/warningSchemeList.html");
				} else {
					base.alert(3, data.message);
				}
			}
		});
	};
	
	return {
		init : init
	};
});